maintainer="Leonardo Arena <rnalrd@alpinelinux.org>"
pkgname=pgcat
pkgver=0.2.1
pkgrel=0
pkgdesc="PostgreSQL pooler with sharding, load balancing and failover support"
url="https://github.com/postgresml/pgcat"
arch="aarch64 armhf armv7 x86 x86_64"
license="MIT"
makedepends="cargo rust"
subpackages="$pkgname-openrc"
options="net"
case "$CARCH" in
	armhf|armv7|x86)
		options="$options !check" # 6 tests out of 27 failing. See commit log for details.
		;;
esac
source="https://github.com/postgresml/pgcat/archive/refs/tags/pgcat-$pkgver.tar.gz
	$pkgname.initd"
builddir="$srcdir/$pkgname-$pkgname-$pkgver"

build() {
	cargo build --release
}

package() {
	install -Dm0755 "$builddir/target/release/$pkgname" "$pkgdir/usr/sbin/$pkgname"
	install -Dm0644 "$builddir/$pkgname.toml" "$pkgdir/etc/$pkgname/$pkgname.toml"
	install -Dm0755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
}

check() {
	cargo test
}

sha512sums="
e5236a097dad612f935cf4a443d438700c1a1c0f2efc30b983d04a545b7339a27b322c510ea6fe322622954be18c1a60200febc8dddfd77d646adc2f7de8b26e  pgcat-0.2.1.tar.gz
2c137dd81c7d367a334426122ad8c8f5298c418fe0fcb21d24793d5aa91f76f9ce70864058cc665aeb56136ba2ed7ba0835bc244ae98e7b27fd96e3b47d6231a  pgcat.initd
"
